Joint inference of exclusivity patterns and recurrent trajectories from tumor mutation trees

Cancer progression is an evolutionary process shaped by both deterministic and stochastic forces. Multi-region and single-cell sequencing of tumors enable high-resolution reconstruction of the mutational history of each tumor and highlight the extensive diversity across tumors and patients. Resolving the interactions among mutations and recovering recurrent evolutionary processes may offer greater opportunities for successful therapeutic strategies. To this end, we present a novel probabilistic framework, called TreeMHN, for the joint inference of exclusivity patterns and recurrent trajectories from a cohort of intra-tumor phylogenetic trees. Through simulations, we show that TreeMHN outperforms existing alternatives that can only focus on one aspect of the task. By analyzing datasets of blood, lung, and breast cancers, we find the most likely evolutionary trajectories and mutational patterns, consistent with and enriching our current understanding of tumorigenesis. Moreover, TreeMHN facilitates the prediction of tumor evolution and provides probabilistic measures on the next mutational events given a tumor tree, a prerequisite for evolution-guided treatment strategies.

Tumors emerge and develop malignancy through a somatic evolutionary process of accumulating selectively advantageous mutations in cells 1 . The genetic and phenotypic clonal diversity within a tumor, also known as intratumor heterogeneity (ITH), enables tumor cells to quickly adapt to micro-environmental changes, including those induced by treatment, often leading to lethal outcomes due to metastases or drug resistance 2,3 . Despite the inherent stochasticity of tumor evolution, recent evidence supported by increasingly available data and new computational methods has revealed at least some repeated features in tumor progression, such as frequently mutated genes 4 , specific order constraints on mutations 5,6 , and repeated evolutionary trajectories [7][8][9][10] . The ability to recover reproducible features of cancer evolution, and more importantly, to make reliable predictions of future evolutionary steps, is crucial for the development of successful therapeutic interventions [11][12][13][14] .
Recent advances in multi-region sequencing 15,16 , single-cell sequencing 17 , and phylogenetic tree inference 18,19 enable more precise characterization of clonal architecture and provide a clearer picture of tumor evolution. However, the increased resolution further substantiates the extensive variability in the subclonal compositions and mutational histories between tumors, making it more challenging to infer repeatable elements. For example, two parallel studies of acute myeloid leukemia (AML) using single-cell panel sequencing 20,21 show that the reconstructed trees typically contained a small number of clones based on the specific driver mutations that were part of the panel and that they varied considerably between any two patients. In particular, both studies report over-represented pairs of co-occurring or clonally exclusive mutations in the subclones. These relationships have recently been examined with a customized statistical test, called GeneAccord 22 , which is designed for evolutionary-related samples from the same tumor. Mutations that co-occur more frequently in the same clonal lineage may indicate synergistic effects on cell proliferation and survival 4 . Clonally exclusive mutations, on the other hand, occur more frequently in different lineages. They may suggest either clonal cooperation, where cell populations harboring complementary sets of mutations collaborate to promote tumor growth 23 , or synthetic lethality, meaning that acquiring both mutations on the same genome will significantly reduce the viability of the clone 24 . Since clonal interactions have a major impact on intratumor heterogeneity and the observed evolutionary trajectories, it would be natural to incorporate mutational interdependencies within and between subclones when modeling tumor progression.
For cross-sectional bulk sequencing data, where each tumor is summarized by a binary genotype, a collection of probabilistic methods for inferring the temporal order of mutations and predicting tumor progression is called cancer progression models (CPMs) 25,26 . In light of the observation that mutually exclusive mutations are often associated with genes in the same functional pathway, Raphael & Vandin developed the first CPM that jointly infers sets of mutually exclusive mutations and the temporal order among them using a chain model 27 . Later, pathTiMEx 28 generalized the linear structure with a continuous-time Conjunctive Bayesian Network (CBN) 29 . A recent method, called Mutual Hazard Networks (MHNs), does not explicitly group exclusive mutations but re-parameterizes mutational waiting times using a matrix that encodes both co-occurrence and exclusivity 30 . However, these methods require independent samples of binary genotypes as input. As such, they have not been designed for tree-structured data as they cannot capture the subclonal structure and dependencies within a tumor nor utilize the existing order information from the tumor phylogenies. In addition, mutual exclusivity is defined at the patient level, whereas clonal exclusivity refers to pairs of mutations that occur less frequently in the same subclone but can still co-exist in the same tumor 22 . Hence, the consensus genotype of a tumor can contain some or all of the clonally exclusive mutations, but the above CPMs will treat them as evidence of co-occurrence.
First efforts have been made to infer recurrent evolutionary trajectories in a cohort of tumor phylogenies reconstructed from bulk, multi-region, or single-cell sequencing data. Based on transfer learning, REVOLVER 7 infers the phylogenetic trees for a cohort of patients simultaneously and reconciles the heterogeneous trees using a matrix summarizing the frequencies of all pairwise ancestor-descendant relationships across tumors and outputs the trees having the smallest distance to the matrix. The entries in the normalized matrix are empirical estimates of the probability of one mutation being the ancestor of another mutation, which can be used to compute the probability of a possible evolutionary trajectory. HINTRA 8 extends the idea of REVOLVER by relaxing the assumption that the occurrence of a mutation depends only on its direct ancestor. It considers all possible sets of ancestors, allowing for more complex dependencies. However, the number of rows of the modified count matrix is exponential in the number of mutations, which limits the scalability of the algorithm 9 . Another direction is to find deterministic patterns from the mutation trees. RECAP solves an optimization problem that simultaneously clusters the patients into subgroups and selects one consensus tree for each cluster 9 . CONETT 10 and MASTRO 31 are computational methods to identify significantly conserved evolutionary trajectories by expanding the tumor trees into graphs that satisfy all partial order relations among the mutations. The former searches for a single conserved evolutionary trajectory tree that can describe the pattern in as many tumors as possible, whereas the latter outputs all such trajectory trees observed in at least a certain number of tumors. These deterministic methods do not provide probabilistic measures of future events given a trajectory or a tree and thus cannot be easily adapted for evolutionary predictions.
Here, we present a novel CPM, called TreeMHN, for simultaneous inference of patterns of clonal exclusivity and co-occurrence and repeated evolutionary trajectories from a cohort of intra-tumor phylogenetic trees. Unlike classical CPMs, including the genotype MHN method 30 , TreeMHN considers the complete mutational histories of tumors and the dependencies between their subclonal structures represented by the intra-tumor mutation tree rather than the overall presence and absence of mutations. Compared to current state-of-theart methods for detecting recurrent trajectories, TreeMHN is probabilistic and explicitly incorporates the exclusivity patterns of mutations. Using simulated data, we demonstrate the superior performance of TreeMHN in estimating the clonal exclusivity parameters and the probability distribution of evolutionary trajectories as compared to the genotype MHN method 30 , REVOLVER 7 , and HINTRA 8 . We then apply TreeMHN to three cancer cohorts: acute myeloid leukemia (AML) 21 , non-small-cell lung cancer (NSCLC) 15 , and breast cancer 32 . Our estimated exclusivity patterns and most probable evolutionary trajectories not only confirm previous biological findings but also provide new insights into the interdependencies of mutations, which could be informative for clinical decisions. With longitudinal tumor samples, TreeMHN provides improved predictions on the next mutational events given a tumor tree over alternative methods, which highlights the potential for evolution-based precision treatment plans.

TreeMHN overview
We developed TreeMHN, a probabilistic model for inferring exclusivity patterns of mutations and recurrent evolutionary trajectories from tumor mutation trees. A tumor mutation tree T is a rooted tree that encodes the evolutionary history of a tumor 33 . The root corresponds to the start of the evolutionary process with no mutations (gray nodes in Fig. 1). The nodes represent the mutations connected according to the order in which they occur and fixate in the cell population (colored nodes in Fig. 1). Each path from the root to a node in the tree constitutes an evolutionary trajectory π, which characterizes the successive accumulation of mutations and uniquely defines a subclone. Starting from an existing subclone π, we assume that the time until a new mutation i occurs and fixates, resulting in a new subclone (π, i), follows an exponential distribution with its rate dependent on not only mutation i but also all ancestor mutations in π. We parameterize the rates using a Mutual Hazard Network (MHN) Θ = e θ ij À Á i, j2½n 2 R n × n , where n is the number of mutations. The diagonal entries fΘ ii g i2½n are the baseline rates of evolution, indicating how quickly each mutation will occur and fixate in a subclone independent of the other mutations. Mutations can have positive (co-occurring), negative (exclusive), or zero (no) effects on the rates of further downstream mutations. This is encoded by the offdiagonal entries fθ ij g i, j2½n with an equivalent graphical structure ( Fig. 1). If θ ij is positive, mutation j increases the rate of mutation i (denoted by an edge j → i). If θ ij is negative, mutation j decreases the rate of mutation i, (denoted j⊣i). The topology of a mutation tree is jointly determined by the waiting times of the subclones and an independent sampling time, which is also exponentially distributed. Only subclones acquired before the sampling time are observable in a tree. Therefore, the marginal probability of observing a tree T given Θ is equal to the probability that all observed mutational events happen before the sampling event, and all unobserved events that could happen next do not happen before the sampling event.
To perform inference with TreeMHN, the input is a set of N independent tumor mutation trees with a total number of n mutations, which can be constructed from bulk, multi-region, or single-cell sequencing data using phylogenetic methods. The output isΘ, an estimated MHN describing the exclusivity and co-occurrence patterns of mutations for the given cohort. With our efficient parameter estimation scheme based on regularized maximum likelihood estimation and a hybrid Monte Carlo expectation-maximization algorithm, the computational complexity depends on the maximum tree size, which is typically much smaller than the number of mutations. The number of parameters to estimate (n 2 ) often exceeds the number of observations (N). To prevent model overfitting, we can run TreeMHN with stability selection 34 , where the parameters in Θ are estimated over many subsamples of the trees, and only those having a high probability of being non-zero are kept. This procedure can significantly improve the precision of identifying the true relationships among the mutations. Furthermore, the estimated model allows us to compute the probabilities of different evolutionary trajectories or evaluate the most likely next mutational events given a tumor tree. We provide an overview of the inference procedure in Fig. 1 and more technical details can be found in Methods and Supplementary Materials.

Performance assessment on simulated data
Through simulations, we assess the performance of TreeMHN in comparison to alternative methods in estimating exclusivity patterns and associated distributions of evolutionary trajectories from mutation trees. For each simulation run, we randomly generate a ground truth network Θ with n mutations and a set of N mutation trees. Using the N simulated trees as input, we run TreeMHN along with the genotype MHN method 30 , REVOLVER 7 , and HINTRA 8 . We consider different configurations of simulation experiments, including varying the number of mutations n and the number of trees N. For each configuration, we perform 100 repetitions. More simulation details are provided in the Methods.
We first evaluate how well TreeMHN can estimate the patterns of clonal co-occurrence and exclusivity by computing the structural differences between the estimated networkΘ and the ground-truth network Θ. Specifically, we measure the precision and recall of identifying the true edges in Θ. An estimated off-diagonal entry inΘ is a true positive if and only if it is non-zero and has the correct sign ( Supplementary Fig. S3). We compare TreeMHN to the genotype MHN method, the only previously published cancer progression model that can estimate Θ (Fig. 2).
In all cases, TreeMHN clearly and consistently outperforms the genotype MHN approach in terms of both average precision and recall. This is because the problem of inferring an MHN from binary genotypes is in general underspecified, meaning that multiple different MHNs share similar likelihoods 35 , which cannot be alleviated by taking subclonal genotypes directly as input. This result highlights the benefit of utilizing the existing ordering information encoded in the trees to resolve the underlying network. In fact, this benefit is maintained even if high levels of noise are added to the trees (Supplementary Figs. S5 and S6), as well as for varying proportions of zero entries (Supplementary Fig. S7) and negative entries in Θ (Supplementary Fig. S8). The difference between the networks estimated using MLE and MC-EM is small and decreases with increasing number of Monte Carlo samples ( Supplementary Fig. S9).
For TreeMHN and genotype MHN, we additionally implemented the stability selection procedure over a set of regularization parameters γ ∈ {0.05, 0.1, 0.5, 1, 1.5, 2, 2.5, 3}, where larger values of γ promote sparser network structures and prevent model overfitting (Methods). The performance of both methods improves as the number of trees increases and the number of mutations decreases. At the same regularization level, the solutions with stability selection achieve much higher precision although at the cost of lower recall. By sorting the rows and columns ofΘ by descending baseline rates, we notice that both methods perform better in recovering the pairwise interactions between mutations with higher baseline rates than those with lower baseline rates ( Supplementary Fig. S4). The reason is that interactions between rare mutations can hardly be observed in the trees, leading to a lack of statistical power to correctly estimate the corresponding entries in Θ. This limitation is in general methodindependent.
Next, we assess the performance of TreeMHN in estimating trajectory probabilities (Fig. 3). For comparison we also include REVOLVER and HINTRA, two probabilistic approaches for detecting repeated trajectories. Across different numbers of mutations and trees, TreeMHN outperforms all alternatives. HINTRA has the worst performance, possibly because of over-parameterization given the limited number of observations for every possible ancestry set. REVOLVER has similar performance as genotype MHNs even though it does not explicitly model co-occurrence and exclusivity between mutations. The genotype MHN method is unable to handle the case n = 30 due to exponentially increasing space and time complexity 30 . For TreeMHN, the runtime and memory are instead limited by the tree with the maximum number of subtrees ( Supplementary  Fig. S10).

Application to acute myeloid leukemia data
We apply TreeMHN to the cohort of N = 123 AML patient samples analyzed in ref. 21 by high-throughput single-cell panel sequencing, which involves 543 somatic mutations in n = 31 cancer-associated genes and does not include any synonymous mutations. We assume that the mutation trees reconstructed by SCITE 33 , a single-cell phylogenetic method, represent the complete evolutionary histories of the tumors. Assuming all point mutations in the same gene have similar effects, we summarize the mutations at the gene level and observe many mutated genes appearing more than once in two separately evolved subclones of the same tree, such as FLT3, KRAS, and PTPN11 21 (Supplementary Section E.1). This recurrence increases the statistical power for detecting recurrent gene-level trajectories and patterns of clonal exclusivity.
To avoid overfitting, we train TreeMHN with stability selection and obtain a network over the 15 mutated genes which have non-zero off-diagonal entries ( Fig. 4 and Supplementary Fig. S11). The sparseness of the network is because the number of observations for the pairwise interactions between rare events is so small that the corresponding entries are filtered out during stability selection. In this case, even if an interaction exists, there may not be enough power to detect it.
Among the 31 AML genes, DNMT3A has the highest baseline rate, followed by IDH2, FLT3, NRAS, NPM1, and TET2, which are known to be more frequently mutated in AML patients 36 . However, these genes do not necessarily appear in every mutation tree or are the initiating events, since the appearance of a mutation depends not only on the baseline rate but also on whether other mutations happened upstream with promoting or inhibiting effects, which further explains the high degree of heterogeneity in the trees. By comparing the off-diagonal entries against the list of gene pairs found by GeneAccord 22 on the same dataset, we observe highly consistent but more informative results. In particular, most significant pairs of co-occurring or exclusive genes can be confirmed in the estimated network with additional directional strengths. For example, GeneAccord identifies NRAS and FLT3 as significantly clonally exclusive. TreeMHN further reveals that the effect of FLT3 inhibiting the occurrence of NRAS in the same lineage is much stronger than the other way around. In other words, if a subclone has already acquired mutations in FLT3, then it is less likely to accumulate another mutation in NRAS, which may still occur in separately-evolved subclones. On the contrary, subclones that acquire mutations in NRAS first are still relatively likely to hit FLT3 subsequently. Apart from with NRAS, such a relationship also appears with PTPN11 and IDH2. This observation aligns with previous studies 37 , where some patients (e.g., 3/11 in ref. 38 and 15/41 in ref. 39) developed secondary resistance to FLT3 inhibitors due to off-target mutations (e.g., genes in the RAS pathways), which were present in small cell populations prior to treatment.
Next, we infer the most probable evolutionary trajectories from the estimated network (Methods and Fig. 5), which are consistent with the significantly conserved ones identified by CONETT 10 and MASTRO 31 (Supplementary Figs. S12 and S13). In comparison to alternative methods, the probabilities estimated by TreeMHN match closer in rankings with the relative frequencies of the observed AML trajectories (Supplementary Figs. S14 and S15). Mutations in DNMT3A, NPM1, and FLT3 often co-occur with a relatively high probability. This threeway interaction is found to be associated with poor prognosis 40,41 . With DNMT3A → NPM1 and NPM1 ⊣ DNMT3A, the ordering between them is more likely to be DNMT3A first followed by NPM1, which has been reported in previous studies 42,43 . Moreover, conditioned on the estimated network and a given tumor tree, we can predict the most probable next mutational event (Methods). To evaluate TreeMHN predictions, we perform both retrospective predictions on the rooted subtrees of the 123   Supplementary Fig. S11, and only mutations with non-zero offdiagonal entries are shown here. The columns and rows of the matrix are ordered by decreasing baseline rates, which are shown on the left in yellow scale. The empty off-diagonal entries represent the case of no effect (θ ij = 0), meaning that there is no edge from mutation j to mutation i. The red blocks correspond to inhibiting effects (θ ij < 0, j⊣i) and the blue promoting effects (θ ij > 0, j → i). The darker the colors, the stronger the effects. Source data are provided as a Source Data file.

Method TreeMHN
Genotype MHN REVOLVER HINTRA Article https://doi.org/10.1038/s41467-023-39400-w primary tumor trees and forward predictions using the longitudinal samples in the same dataset ( Fig. 9). A comparative analysis against five alternatives (TreeMHN that estimates only the baseline rates of mutations, genotype MHN on consensus genotypes, genotype MHN on weighted subclonal genotypes, REVOL-VER, and a frequency-based model that predicts the next events using the relative frequencies of the mutations in the cohort) reveals better predictive performance of TreeMHN. For the majority of the 123 primary tumor trees, TreeMHN assigns higher rankings to the events that actually happened downstream of any of the rooted subtrees ( Fig. 6 & Supplementary Fig. S17). Under TreeMHN, seven out of nine new events in consecutive longitudinal samples have higher predicted probabilities than over 94% of the other possible mutational events, whereas alternative methods give varying predictions which are worse on average than TreeMHN (Table 1 and Supplementary Fig. S18). For instance, given the tree of patient sample AML-38-002, TreeMHN successfully identifies the two relapse events (Root → NPM1 → IDH2 → PTPN11 and Root → NPM1 → IDH1 → FLT3 in AML-38-003) in the top 5% most probable mutational events. With treatment effects drastically altering the fitness landscape 44 , it is possible that subclones that were too small to detect at diagnosis became more abundant in a relapse. The consistent predictions highlight the ability of TreeMHN to unravel the interplay among the mutational events from the heterogeneous mutation trees, offering opportunities for evolution-guided treatment strategies.
Application to non-small-cell lung cancer data Next, we analyze the TRACERx NSCLC multi-region whole-exome sequencing data for N = 99 patients 15 . By applying TreeMHN to the phylogenetic trees with n = 79 driver mutations from ref. 7 (Supplementary Section F.1), we detect stable signals of interdependencies among 18 mutations ( Fig. 7 and Supplementary Fig. S19). The majority of these interactions are from KRAS, TP53, and EGFR to other genes, suggesting their essential roles as recurrent initial events in tumorigenesis and progression 6,15 . In particular, the exclusive relationship between the oncogenic drivers KRAS and EGFR aligns with previous studies and could be associated with different clinical features (e.g., smoking exposure) between KRAS-mutant and EGFRmutant subgroups 45,46 . Each of these two mutations is co-occurring with TP53, one of the most commonly mutated tumor suppressor genes in NSCLC 47 . EGFR-mutant tumors with co-occurring TP53 were found to have higher degrees of genomic instability and shorter progression-free survival after EGFR TKI therapy 48 . Co-mutations in KRAS/TP53, on the other hand, are predictive for favorable clinical response to PD-1 inhibitors 49 . Moreover, existing EGFR mutations may encourage the occurrence of mutations in TERT and PIK3CA, where the former can influence telomere maintenance mechanisms in tumor cells 50 , and the latter promotes cellular invasion and migration in vitro 46 . Both are associated with poor overall survival 46,50 . These observations indicate that the tumor progression processes leading to the observed co-occurrence of the genes may have direct clinical consequences.  Without reconciling the trees or clustering the trees into subgroups, the most probable evolutionary trajectories inferred by TreeMHN capture most of the repeated trajectories found by REVOL-VER ( Supplementary Fig. S20). Notably, we recover 7 of the 10 REVOLVER clusters (C2, C3, C4, C6, C7, C9, C10) in the top 50 trajectories ( Supplementary Fig. S21), underlining the ability of TreeMHN to disentangle noisy signals. For cluster C7, TreeMHN assigns a higher probability to the trajectory KRAS → TP53 → MGA as compared to TP53 → KRAS → MGA, whereas REVOLVER cannot tell them apart. Interestingly, the trajectory CDKN2A → TP53 in cluster C5, identified as highly robust by REVOLVER, has a lower probability than TP53 → CDKN2A, where the ordering is reversed. As pointed out in ref. 15, most of the mutations in TP53 were clonal for both adenocarcinoma and squamous-cell carcinoma in the TRACERx dataset, whereas mutations in CDKN2A appeared mostly in the latter subtype and often late. Hence, it is more likely that mutations in TP53 precede those in CDKN2A, hinting at how they cooperate on cell-cycle deregulation.

Application to breast cancer data
Finally, TreeMHN is not restricted to tumor trees reconstructed from single-cell or multi-region sequencing data, and we analyze a bulk sequencing dataset of 1918 tumors for 1756 advanced breast cancer patients, where clinical data is also available 32 . Based on hormone receptor and HER2 status (HR+/HER2+, HR+/HER2-, HR-/HER2+, Triple Negative) and sample type (treatment-free primary vs. metastasis), we can segregate the patients into eight subgroups. Considering only copy-neutral autosomal regions, we restrict the analysis to the union of SNVs that appear in at least 10% of the patients in each subgroup. In total we have n = 19 mutations and N = 1152 patients with 1232 phylogenetic trees inferred by SPRUCE 51 , a phylogenetic method based on bulk mixture deconvolution (Supplementary Section G.1).
The estimated network on all trees captures combined signals, which are mainly driven by the largest subgroups with HR+/HER2status ( Supplementary Fig. S22). We observe that mutations in TP53 and PIK3CA, which were identified as early clonal events 6,8,32 , have the highest baseline rates of mutations and are co-occurring. We also detect exclusivity between PIK3CA and PIK3R1, suggesting that mutations in one of these drivers may suffice to trigger abnormal regulation of PI3K activation in breast cancer 52 . While there are no large deviations from the combined network, we obtain some subgroup-specific interdependencies by applying TreeMHN separately to each subgroup ( Supplementary Figs. S23 and S24). For example, NF1 mutations, which are found to be associated with endocrine resistance 32 , have higher baseline rates in hormone receptor-negative tumors and cooccur with TP53 more frequently in metastatic samples. Also, we detect co-occurrence of PIK3CA and GATA3 in hormone receptor-positive tumors but not in the negative ones. It has been observed that tumors with GATA3 mutations depend more on estrogen level and may be predictive for positive response to aromatase inhibitors 53 . The subgroup-level most probable evolutionary trajectories not only confirm existing findings reported by HINTRA 8 and RECAP 9 , such as CDH1 → PIK3CA for the HR+/HER2-samples, but also provide new insights ( Supplementary Figs. S25-S28). For instance, the combination of TP53, PTEN, and PIK3CA/PIK3R1 ranks higher in the metastatic triple- negative subgroup than in other subgroups. Cooperatively, these mutations can lead to hyperactivation of the PI3K-AKT pathway and uncontrolled proliferation of cells, ultimately reducing the overall survival rate 54 . Therefore, TreeMHN is capable of extracting key patterns related to clinical outcome from highly heterogeneous tumor mutation histories.

Discussion
We have developed TreeMHN, a novel cancer progression model for the joint inference of repeated evolutionary trajectories and patterns of clonal co-occurrence or exclusivity from a cohort of intra-tumor phylogenetic trees. Unlike Mutual Hazard Networks 30 , TreeMHN can take as input heterogeneous tree structures estimated from multiregion, single-cell, or bulk sequencing data, rather than per-tumor or per-clone consensus genotypes. Importantly, with our efficient parameter estimation procedure, it is the maximum tree size, rather than the total, typically much larger, number of mutations, that limits the computation time of TreeMHN.
Through simulation studies, we have demonstrated the superior performance of TreeMHN in estimating both patterns of clonal exclusivity or co-occurrence and trajectory probabilities in comparison with MHNs, REVOLVER, and HINTRA. Moreover, we have shown that TreeMHN is robust against uncertainty in the phylogenetic trees for varying noise levels. Alternatively, one may handle such uncertainty by sampling the trees for each patient proportionally to their posterior probabilities and taking them as weighted inputs to TreeMHN. By exploiting the evidence of temporal ordering among mutations contained in the tree topologies and properly accounting for clonal dependencies, TreeMHN can better resolve the underlying network structure. Given the estimated parameters, TreeMHN allows us to compute the probabilities of different evolutionary trajectories and the expected waiting times between mutational events. However, in general, these waiting times cannot be interpreted as real calendar time since they are with respect to the unknown sampling times and the scaling factor is therefore unknown. One remedy is to use longitudinal data, where the sampling time is either provided or can be inferred from data. Including observed sampling times is technically possible 55 , but such data are often difficult to obtain without having treatment interventions. Modeling drug response data is a crucial but challenging direction to explore, for which TreeMHN may serve as a basis.
Unlike REVOLVER and HINTRA, our method embraces the heterogeneity among the trees and incorporates clonal exclusivity and cooccurrence into the analysis of recurrent evolutionary processes. Also, TreeMHN does not rely on any particular phylogenetic method. It is possible to combine different phylogenies from various sources (e.g., refs. 33,56,57 ) to take into account different modeling assumptions. Future developments in phylogenetic methods together with more available data can further improve the estimate of TreeMHN. Another advantage of TreeMHN is the ability to model parallel mutations in distinct lineages, which are not uncommon in real data 21 , while many of the existing alternatives require the infinite sites assumption. Like all other progression models, however, TreeMHN currently does not consider back mutations, i.e., situations in which a mutation is acquired at first but subsequently lost 58,59 . A possible extension along this line is to include additional parameters and use as input phylogenetic trees inferred by methods such as SCARLET 60 , which views a decrease in copy numbers that overlap a mutated locus as evidence of back mutations. Moreover, TreeMHN is not designed for a specific type of mutation, such as SNVs. In other words, it is possible to detect recurrent trajectories at the level of copy number alterations 61 , mixed types of mutations 62 , or even functional pathways 63 .
Nevertheless, TreeMHN does not take into account the subclone sizes, which can be viewed as consequences of clonal selection 64  Article https://doi.org/10.1038/s41467-023-39400-w have promise but is challenging. On the one hand, larger subclone sizes can be attributed to both their earlier appearance or higher fitness 65 . On the other hand, the mutation rates in cancer progression models are rates of evolution, which implicitly involve subclone fitness. Thus, any attempts to modify TreeMHN to model clonal selection need to be taken with caution. In this work, we assumed all trees in the same cohort are generated from one MHN, but it is possible to extend TreeMHN to perform model-based unsupervised clustering akin to ref. 66. We have applied TreeMHN to data of three different cancer types and demonstrated its practicality and flexibility. Beyond reproducing existing results, TreeMHN provides additional insights, including baseline rates of mutational events, directional strengths of the promoting or inhibiting effects, as well as probabilistic measures of evolutionary trajectories. In particular, we find good overlap between the longitudinal AML data 21 and our predictions of the next mutational events. The application and results of TreeMHN may therefore be useful for prioritizing personalized treatments.

TreeMHN generative model
TreeMHN models mutation trees using a tree-generating process. Consider N mutation trees T = fT 1 , . . . ,T N g with a total number of n mutations. Each tree T l corresponds to the mutational history of a tumor and contains a subset of mutations from [n] ≔ {1,…, n}. We assume that the trees are realizations of a Markov process with the transition rate matrix parameterized by a Mutual Hazard Network Θ 2 R n × n . We denote each subclone in a tree by the evolutionary trajectory π that runs from the root 0 to the node where the subclone is attached. In other words, a subclone π is a sequence (0, σ 1 ,…,σ d ) with 0 ≤ d ≤ n, and σ i ∈ [n] are non-duplicated elements. Let Π denote the space of all subclones, or equivalently, the space of all evolutionary trajectories. The tree-generating process is defined as follows (Fig. 8,  Supplementary Sections A.1 and A.2): 1. The initial wild-type subclone is π = (0) at time T (0) = 0. For each subclone π, the set of mutations that could happen next is [n]⧹π. 2. The waiting time until a new subclone (π, i) with i ∈ [n]⧹π is born from π is an exponentially distributed random variable, T ðπ,iÞ ∼ T π + Expðλ ðπ,iÞ Þ, where θ ii = log Θ ii is the baseline rate of mutation i, and θ ij = log Θ ij determines the positive (denoted j → i), negative (j⊣i) or zero effect of Pattern of exclusivity and co−occurrence = {T π } π∈Π Fig. 8 | TreeMHN as a probabilistic graphical model. The waiting times of subclones T = fT π g π2Π are exponentially distributed random variables parameterized by an MHN Θ = ðe θ ij Þ i,j2½n . The tree structure T is jointly determined by T and an independent sampling time T s , which is also an exponential random variable with rate λ s . Both T and T s are hidden variables. The random variables inside the plate replicate N times, which generate N independent and identically-distributed mutation trees.
an existing mutation j on mutation i 30 . If both θ ij < 0 and θ ji < 0 (i.e., j⊢⊣i), then the two mutations are called clonally exclusive, and if both signs are positive (i.e., j ↔ i), we say that the mutations are cooccurring. The collection of all waiting times is denoted by T = fT π g π2Π . 3. The observed tree structure T is co-determined by an independent sampling event S with time T s ∼ Expðλ s Þ. Typically, we assume λ s = 1 for identifiability 29 . An edge from π to (π, i) exists in T if and only if T (π, i) < T s , i.e., if mutation i happened before sampling the tumor cells. 4. The process iterates until all subclones that could emerge next have a longer waiting time than the sampling time. We denote the augmented tree structure by AðTÞ, which includes the edges pointing towards the events right after sampling ( Supplementary  Fig. S1b). Events further downstream are not considered as they cannot influence the observed tree structure.
One advantage of this formulation is that the same mutational event can appear in different lineages of a tree. For computational convenience, many of the alternatives capable of inferring repeated evolutionary trajectories (e.g., REVOLVER, HINTRA, RECAP) require the infinite sites assumption (ISA), i.e., each mutational event (e.g., an SNV) is gained at most once. However, it has been shown that allowing parallel mutations is, in general, a more realistic assumption 58 . Even assuming the ISA for individual genomic bases, when summarizing at the gene level the same gene may be affected in parallel lineages. In results, we demonstrated the applicability of TreeMHN using the AML dataset which contains parallel mutations. Due to the introduction of clonally exclusive mutations, another advantage is the possibility to generate very distinct trees from given mutual hazards. Therefore, TreeMHN can model extensive intra-tumor and inter-tumor heterogeneity, while capturing common, re-occurring features.

Parameter estimation
The marginal probability of observing a tree T conditioned on an MHN Θ is given by (Supplementary Fig. S1), Both pðT|ΘÞ and its gradients ∂pðT|ΘÞ=∂λ π can be computed efficiently by inverting specific triangular matrices, which are constructed using the rates associated with the events in AðTÞ, and the dimensions depend only on the number of subtrees in T (see Theorem 1 and 2 in Supplementary Section A.2 and the derivations in Supplementary Section A.3). Given N mutation trees T = fT 1 , . . . ,T N g, we follow 30 and estimate Θ by maximizing the penalized log-likelihood, where γ > 0 controls the sparsity of Θ in order to mitigate overfitting. When some or all of the trees in T have many subtrees (e.g., more than 500 subtrees), the MLE procedure can still be very slow or even infeasible. In this case, we resort to a hybrid EM and Monte Carlo EM algorithm based on importance sampling as follows (see also Supplementary Section A.4). In the E step, given the observed trees T and the current estimate Θ (k) for iteration k ∈ {0, 1, 2, … }, we compute the expected value of the complete-data log-likelihood with respect to the unobserved collection of waiting times as gðΘ,Θ ðkÞ Þ = X N l = 1 where C is a constant. For small trees, we can calculate the expected time difference in exact form, E T ,T s |T,Θ ½T ðπ,iÞ À T π = 1 λ ðπ,iÞ À 1 PðT|ΘÞ For large trees, we approximate the expectation by drawing M samples from the following proposal distribution. First, the sampling time T s ∼ Expðλ s Þ with λ s = 1 is drawn independently. Using the equation T (π, i) = T π + Z (π, i) , we then follow the topological order in T and sample the difference in waiting times between subclones π and (π, i) recursively as Z ðπ,iÞ ∼ TExpðλ ðπ,iÞ , 0, t s À t π Þ if ðπ, iÞ 2 T TExpðλ ðπ,iÞ , t s À t π , 1Þ if ðπ, iÞ 2 AðTÞ n T ( where TExpðλ, a, bÞ is the truncated exponential distribution with parameter λ and bounds 0 ≤ a < b < ∞. Thus, the time points t (m) and t ðmÞ s Fig. 9 | A schematic representation of evaluating the predictions of next events given a tree structure. AML-83-001 is a tumor sample, and the associated mutation tree is a chain with two mutations. Given this tree, we can retrospectively enumerate all its rooted subtrees and compute the probability of the existing downstream events. AML-83-002 is a consecutive sample available for the same patient, with which we can perform forward prediction and validate the result. The root node is in gray, the events that are common from a preceding tree are in blue, and the new events are in pink.
for m = 1, …, M generated from our proposal distribution are by definition compatible with the tree structure. The approximation is then E T ,T s |T,Θ ½T ðπ,iÞ À T π ≈ In the M step, we update Θ by maximizing the penalized expected complete-data log-likelihood To prevent overfitting, we run TreeMHN with stability selection 34 such that the parameters in Θ are estimated over many subsamples of the trees T, and only those having a high probability of being non-zero are kept (see also Supplementary Section B). The choice of parameter estimation method is automatically determined by a pre-specified number of subtrees: if the maximum number of subtrees of all trees in the set is below this threshold, then MLE is used. Otherwise, we use the hybrid MC-EM method instead. By default, the threshold is set to be 500 subtrees, and the number of Monte Carlo samples is M = 300.

Probability and expected waiting time of a trajectory
We consider the set of evolutionary trajectories that end with the sampling event S, Given Θ and λ s , we can compute the probability of a trajectory π ∈ Π S as the product of competing exponentials, where π i = (0, σ 1 ,…,σ i ) ⊂ π. It follows that ðP Θ ðπÞÞ π2Π S is the probability distribution over Π S with respect to Θ, since P π2Π S P Θ ðπÞ = 1. Likewise, the expected waiting time of π ∈ Π S is the sum of the expected time interval lengths along the trajectory, However, computing P Θ (π) for all π ∈ Π S is computationally infeasible for large n, since the number of trajectories in Π S is factorial in n. Instead, we can enumerate the most probable trajectories that have at least one mutation with dynamic programming following the pseudocode in Supplementary Algorithm 2, the complexity of which is linear in n.
To compare with alternative methods that do not contain a sampling event, such as REVOLVER 7 and HINTRA 8 , we can use another formulation with Π d ⊆ Π, which is the set of evolutionary trajectories of a fixed length d for 1 ≤ d ≤ n. The probability of a trajectory π ∈ Π d can be computed similarly as and P π2Π d P Θ ðπÞ = 1. Note that in this formulation, trajectories of different lengths are not directly comparable, but it is still useful as a tool to validate an estimated trajectory probability distribution. Suppose Q is another probability distribution over Π d , then the Kullback-Leibler (KL) divergence from Q to P Θ , measures the distance between the two distributions. In particular D KL (P Θ ∥Q) = 0 if and only if P Θ = Q.
Probability of a downstream event given a tree Given a tree structure T and an estimated network Θ, we can compute the probabilities of the next mutational events. The events that could happen next are all events in the augmented tree AðTÞ but not in T. By competing exponentials, we calculate the probability of an event π happens before all the other events in AðTÞ n T as where λ π is the rate associated with event π (Eq. (1)). Then, we can rank all events π 2 AðTÞ n T by their probabilities. We evaluate TreeMHN predictions on the AML dataset 21 . We perform both retrospective predictions on the rooted subtrees of the 123 primary tumor trees and forward predictions using the longitudinal samples from 15 patients in the same dataset (Fig. 9). For retrospective predictions, we first take a primary tumor tree and exclude it from training. Then, we enumerate all its rooted subtrees and their corresponding downstream events, followed by computing the probability of each downstream event conditioned on a parent subtree and the estimated network (Eq. (14)). For forward predictions, on the other hand, we take the longitudinal samples and consider only those tree pairs on consecutive time points, where the second tree has mutations not present in the first tree. We compute the probabilities for the new events using the matrix estimated from the 123 primary tumor trees (i.e., longitudinal samples are excluded from training). While TreeMHN is unique in this task, we adapt five alternative methods for comparison (see also Supplementary Section C.2): • TreeMHN (baseline): Here, we run TreeMHN with the restriction that all off-diagonal elements in the estimated network are zero and keep only the baseline rates. This approach assumes that all mutations are independent of each other while respecting the tree structures. The way to compute the probabilities of the next mutational events given a tree stays the same. • MHN (consensus): We estimateΘ MHN using the genotype MHN method 30 on the consensus genotypes of the patient samples. A consensus genotype of a tumor is obtained by keeping the mutations that appear in more than 50% of the cell population. GivenΘ MHN , we compute the probabilities of the next events using Eq. (14). • MHN (weighted): This method is the same as MHN (consensus) except for using the subclonal genotypes weighted by the subclone sizes as input to trainΘ MHN . • REVOLVER: We first convert the subclonal genotypes into cancer cell fractions, the proportion of cancer cells having a specific mutation, followed by running REVOLVER to obtain the information transfer matrix w (Supplementary Fig. S16). An entry w ij is the number of times mutation i occurs before mutation j in the patients. By row-normalizing w, we can obtain the empirical probability of mutation j being the descendant of mutation i. The probability of a new event with mutation j can be computed as the probability of randomly selecting a node to place the new event multiplied by the entry w ij if the direct ancestor is mutation i. • Frequency: The simplest benchmark is to predict the next mutational events using the relative frequencies of the mutations in the cohort. The probability of a new event with mutation j can be computed as the probability of randomly selecting a node to place the new event multiplied by the relative frequency of j. For the last two approaches, normalization is required to ensure that the probabilities sum up to 1 over all possible events. We say that a method has better predictive performance if the event that actually happened ranks higher by that method compared to all other possible events. We, therefore, compare the percentile ranks of the next events. In the case of ties, we take the average percentile rank of the tied events.

Simulations
We use simulation studies to assess the performance of TreeMHN in estimating the network parameters Θ and the probabilities of evolutionary trajectories from a set of mutation trees. Following 30 , we first randomly generate a ground truth network Θ with n mutations. The diagonal entries log Θ ii are drawn from a uniform distribution ranging from −6 to −1. A random half of the off-diagonal entries log Θ ij are set to zero, and another half are sampled from a Gamma distribution Γ(α, β) with α = 4 and β = 2.5. The non-zero entries are then multiplied by −1 with a 50% chance. These values are chosen to mimick the AML dataset. Given Θ, we then generate N mutation trees (see pseudocode in Supplementary Algorithm 1), from which we can obtain an estimatê Θ using TreeMHN. In addition to varying the number of mutations n and the number of trees N, we also consider different levels of network sparsity (proportion of zero entries in Θ) and the ratio of positive and negative entries in Θ. Moreover, the tree generating process assumes that each generated tree represents the true mutational history of a tumor. In practice, however, the trees estimated by phylogenetic methods are often noisy. To evaluate the robustness of TreeMHN against the uncertainty in the input tree topologies, we introduce a noise level ϵ ∈ {1%, 5%, 10%, 20%}, the probability of perturbing individual nodes in the simulated trees, and run TreeMHN on the perturbed trees (Supplementary Section D.3).
We first compute the precision and recall of identifying the edges ( j i, j → i, j⊣i) in Θ. Specifically, we call an off-diagonal entry inΘ true positive if and only if it is non-zero and has the correct sign (Supplementary Section D.1). For this metric, we compare TreeMHN against the genotype MHN method, which cannot handle tree structures, since the input is one consensus genotype per tumor. As such, we use the subclonal genotypes as input, weighted by the number of subclones within a tree. Even though the subclonal structure is lost, using multiple genotypes per tumor is still more informative for the genotype MHN method than a consensus genotype.
To benchmark the accuracy of TreeMHN in recovering the trajectory probabilities, we include additionally REVOLVER and HINTRA for comparison. Since these two methods do not have a notion of a sampling event, we use the KL divergence from an estimated trajectory distribution PΘ to the true distribution P Θ over Π d with d = 4 (Eqs. (12) and (13)). Note that longer trajectory lengths can dramatically increase the computational complexity as the number of trajectories in Π d is n! ðnÀdÞ! . Since these two alternatives do not output an estimate of Θ, we compute their key matrices (denoted w in REVOLVER and β in HINTRA) using the edge frequencies directly from the trees, followed by constructing the probability distributions over Π d with the matrix elements (Supplementary Section D.2).

Reporting summary
Further information on research design is available in the Nature Portfolio Reporting Summary linked to this article.

Data availability
The original sequencing data for the AML dataset 21 are available at NCBI BioProject ID PRJNA648656, and the associated mutation trees are provided with this paper. The original sequencing data for the NSCLC dataset 15 are available at the European Genome-Phenome Archive under accession code EGAS00001002247, and the associated mutation trees are obtained from the R package evoverse. datasets (v0.1.0) 67 . The original somatic mutational and clinical data for the breast cancer dataset 32 are available at the cBioPortal for Cancer Genomics with study ID breast_msk_2018, and the associated mutation trees 9 are obtained from https://github.com/elkebir-group/ RECAP/tree/master/data/breast_Razavi. All simulation data, processed mutation trees, and other relevant data are available as Source Data files at Zenodo (https://doi.org/10.5281/zenodo. 7817793). Source data are provided with this paper.
Code availability